package com.cuit.washneedshake.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuit.washneedshake.mapper.ImportedProvincesMapper;
import com.cuit.washneedshake.mapper.NationalMapMapper;
import com.cuit.washneedshake.mapper.NationalNewTrendsMapper;
import com.cuit.washneedshake.mapper.NationalTrendsMapper;
import com.cuit.washneedshake.model.entity.NationalMap;
import com.cuit.washneedshake.service.NationalMapService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;


@Service
public class NationalMapServiceImpl extends ServiceImpl<NationalMapMapper, NationalMap> implements NationalMapService {

    @Resource
    private NationalMapMapper nationalMapMapper;

    @Resource
    private NationalTrendsMapper nationalTrendsMapper;

    @Resource
    private NationalNewTrendsMapper nationalNewTrendsMapper;

    @Resource
    private ImportedProvincesMapper importedProvincesMapper;

    @Override
    public List<NationalMap> getNationalMapList() {
        LambdaQueryWrapper<NationalMap> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(NationalMap::getProvince, NationalMap::getConfirmed);
        List<NationalMap> nationalMaps = nationalMapMapper.selectList(queryWrapper);
        return nationalMaps;
    }

    @Override
    public HashMap<String, Integer> getNationalMapTop() {
        HashMap<String, Integer> map = new HashMap<>();
        //对累计确诊，累计治愈，累计死亡进行求和
        Integer confirmedSum = nationalTrendsMapper.getConfirmedSum();
        Integer curedSum = nationalTrendsMapper.getCuredSum();
        map.put("confirm", confirmedSum);
        map.put("heal", curedSum);
        map.put("dead", nationalTrendsMapper.getDeathSum());
        map.put("nowConfirm", confirmedSum - curedSum);
        map.put("noInfect", nationalNewTrendsMapper.getNew_SuspectedSum());
        map.put("importedCase", importedProvincesMapper.getImportedCasesSum());
        return map;
    }

}




